package com.example.mall.doc;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @Author: xxxliu
 * @CreateTime: 2025-05-20
 * @Version: 1.0
 */
@Document(indexName = "mall",type = "products")
@Data
public class ProductsDoc {

    @Id
    private Long id;
    /**
     * 商品唯一标识
     */
    @Field(type = FieldType.Integer)
    private Long productId;
    /**
     * 商品分类ID
     */
    @Field(type = FieldType.Integer)
    private Long categoryId;
    /**
     * 商品名称
     */
    //课程标题需要分词，和指定分词器
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_max_word")
    private String name;
    /**
     * 商品详细描述
     */
    @Field(type = FieldType.Keyword)
    private String description;
    /**
     * 商品原价
     */
    @Field(type = FieldType.Double)
    private BigDecimal price;
    /**
     * 商品折扣价（如果有）
     */
    @Field(type = FieldType.Double)
    private BigDecimal discountPrice;
    /**
     * 商品库存数量
     */
    @Field(type = FieldType.Integer)
    private Integer stock;
    /**
     * 上架时间
     */
    @Field(type = FieldType.Date)
    private Date onLineDate;
    /**
     * 下架时间
     */
    @Field(type = FieldType.Date)
    private Date offLineDate;
    /**
     * 更新时间
     */
    @Field(type = FieldType.Date)
    private Date updateDate;

    /**
     * 封面
     */
    @Field(type = FieldType.Keyword,index = false)
    private String pic;

    /**
     * 销量
     */
    @Field(type = FieldType.Integer)
    private Integer saleCount;
    /**
     * 浏览量
     */
    @Field(type = FieldType.Integer)
    private Integer viewCount;
    /**
     * 评论数
     */
    @Field(type = FieldType.Integer)
    private Integer commentCount;
}
